home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / Chip_2004-11_cd1.bin / zkuste / dolby / download / dvdlab / DVDlabProRC2b.exe / {app} / Extras / Script / fade.talk < prev    next >
Encoding:
Text File  |  2004-03-22  |  2.8 KB  |  116 lines

  1. /*    Linear Fade 1.0
  2.  
  3.     by Oscar, 12 Dec 2003
  4.     
  5.     To run this: DROP the Script from Assets to the Object in Menu.
  6.     
  7.     this example creates a simple Linear Fade on any object
  8.     You can choose the direction
  9.     Note: because of the bitmap merging, the text will become not-editable after you apply this
  10. */
  11.  
  12. // Get the current menu and selected object when you drag and drop script
  13. // Note: if testing from Script editor make sure you have just one menu opened on desktop,
  14. //       in such case the MenuGetCurSel will return currently opened menu 
  15. menu = MenuGetCurSel() 
  16. // VTS menu 1..255, VMG menu 10001..10255 
  17.  
  18. // show the current menu on top of all others
  19. MenuActivate(menu)
  20.  
  21. object= ObjectGetCurSel(menu) 
  22.  
  23. if (object==0) then
  24.     print "No object Selected"
  25.     end
  26. endif
  27.  
  28. type = LoadInteger("FadeType",0)
  29.  
  30. input "Direction:Vertical Bottom->Top|Horizontal Right->Left|Vertical Top->Bottom|Horizontal Left->Right",type //"CHECK:/FILE:/COLOR:/Combo:item1|item2... 
  31.     
  32. //allow cancel    
  33. if bCancelInput then
  34.     trace "Cancelled"
  35.     end
  36. endif
  37.     
  38. // save grad type to registry
  39. SaveInteger("FadeType",type)
  40.     
  41. //get the image buffer from object and store it in buffer 1
  42. ImgGrabObject(1,menu,object) // imgNum = temporary image buffer 1,2 or 3
  43.  
  44. imgW = ImgGetWidth(1) 
  45. imgH = ImgGetHeight(1)
  46.  
  47. //vertical
  48. steps = imgH
  49.  
  50. //horizontal
  51. if (type==1 | type==3) then
  52.     steps = imgW
  53. endif
  54.  
  55. // one of the parameter in equation has to be float or else the result will be integer
  56. // we will make the steps float number. 
  57. ca = 255.0/FLOAT(steps)
  58.  
  59. // if the other dirrection, make it negative (from 255 +(-ca) to 00)
  60. if type>1 then
  61.     ca=-ca
  62. endif
  63.  
  64. // trace is same as print, but it will appear only in the Output window in editor
  65. trace "Steps =",steps, "ca=",ca
  66.  
  67. // this is interpreter so it is slow!
  68. // show some progress or else people will see nothing happening for while
  69. ProgressBar(0,imgH,"Building Linear Alpha Mask")
  70.  
  71.  
  72. // loop through each pixel and draw the Alpha channel
  73. // we have to combine the new gradient alpha with any existing alpha on the object
  74. // if type = 0,1 we go AA=0 to 255,if 2,3, then we go the other way from AA=255 to 0
  75.  
  76. if (type==0 | type==2) then
  77.     
  78.     // VERTICAL *******************************
  79.     AA=0
  80.     if type>1 then
  81.         AA=255
  82.     endif
  83.  
  84.     for y=1 to imgH
  85.         AA=AA+ca
  86.         ProgressSetPos(y)
  87.         for x=1 to imgW
  88.             mix = ImgGetA(1,x,y)//,AA)
  89.             mix = MIN(mix,AA)
  90.             ImgSetA(1,x,y,mix )
  91.         next x
  92.         
  93.     next y
  94. else
  95.     // HORIZONTAL **************************
  96.     for y=1 to imgH
  97.         AA=0
  98.         if type>1 then
  99.             AA=255
  100.         endif
  101.         ProgressSetPos(y)
  102.         
  103.         for x=1 to imgW
  104.             AA=AA+ca
  105.             mix = ImgGetA(1,x,y)
  106.             mix = MIN(mix,AA)
  107.             ImgSetA(1,x,y,mix)
  108.         next x
  109.     next y
  110.  
  111. endif
  112.  
  113. // now put the img buffer 1 into the object!
  114. ImgSetToObject(1,menu,object)
  115. // remove any shadow
  116. ObjectSetShadow(menu,object,0,0)
  117.